package 数组题目.数组变换;

//验证回文串
//https://leetcode.cn/problems/valid-palindrome/
class 验证回文串 {
    public boolean isPalindrome(String s) {
        StringBuilder waitStr = new StringBuilder();
        for (int i = 0; i < s.length(); i++) {
            char one = s.charAt(i);
            if (Character.isLetterOrDigit(one)) {
                waitStr.append(Character.toLowerCase(one));
            }
        }
        String temp = waitStr.toString();
        int i = 0, j = temp.length() - 1;
        while (i < j) {
            if (temp.charAt(i) != temp.charAt(j)) {
                return false;
            }
            i++;
            j--;
        }
        return true;
    }

    public static void main(String[] args) {
        System.out.println(new 验证回文串().isPalindrome("A man, a plan, a canal: Panama"));
    }
}
